package com.springboot.others.mapper;

import com.springboot.others.entity.UserMybatis;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMybatisMapper {


    @Select("SELECT * FROM user_mybatis WHERE NAME = #{name}")
    List<UserMybatis> findByName(@Param("name") String name);


    @Insert("INSERT INTO user_mybatis(NAME, AGE) VALUES(#{name}, #{age})")
    int insert(@Param("name") String name, @Param("age") Integer age);

    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    @Insert("INSERT INTO user_mybatis(NAME, AGE) VALUES(#{name}, #{age})")
    int insert2(UserMybatis userMyBatis);

    @Delete("DELETE FROM user_mybatis")
    int deleteAll();

    @Delete("DELETE FROM user_mybatis where id = #{id}")
    int deleteOne(Long id);

}